package com.yxym.inversion;

public class DependcyInversion {
    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
    }
}

//完成Person接收消息的功能
//方式1完成
//添加接口，表示接受者，Person类与Receive相互依赖
class Person{
    public void receive(IReceive receive){
        System.out.println(receive.getInfo());
    }
}
class Email implements IReceive{
    public String getInfo(){
        return "电子邮件信息：hello world";
    }
}

interface IReceive{
     String getInfo();
}